<?php
/**
 * 分页起始位置
 *
 * @param $page
 * @param $limit
 * @return float|int
 */
function start($page, $limit)
{
    return ($page - 1) * $limit;
}


function normSortArr($arr , $pidName = 'pid',$parent_id=0,$level=0){
    $res=array();

    foreach($arr as $v){
        if($v[$pidName]==$parent_id){
            $v['disabled']=false;
            foreach($arr as $v1){
                if($v1[$pidName]==$v['id']){
                    $v['disabled']=true;
                    break;
                }
            }

            $v['level']=$level;
            $res[]=$v;
            $res=array_merge($res,normSortArr($arr,$pidName,$v['id'],$level+1));
        }
    }
    return $res;
}